<!DOCTYPE html>
<html>

<head lang="en">
  <meta charset="UTF-8">
  <title></title>
</head>



<body>
  <h5 id="id2">10</h5>
  <button id="id1" onclick="daojishi()">开始倒计时</button>
  <script type="text/javascript">
    let id2 = document.querySelector('#id2')
    let time = parseInt(id2.innerText)
    console.log(time);
    function daojishi () {
      if (time === 0) {
        return
      }
      time--
      id2.innerText = time
      setTimeout(() => {
        daojishi()
      }, 1000);
    }
  </script>
</body>

</html>